******************************************************************************
*                                                                            *
*   Replication file for "Hierarchical Oversight and the Value of Public     *
*         Office: Evidence from Colonial Peru" By Jenny Guardado             *
*                                                                            *
*                              June 2021                                    *   
*                                                                            *
******************************************************************************   


*Set Up

clear all
set more off
*cd "C:\."

*installing necessary packages
cap ssc install outreg2

log using LogAppendixTablesFigures, replace


**************************************
***TABLE A.1 - Members' Exit by Death
**************************************

use indivmemberslima.dta, clear

sort entry

list name birthspain birthlima purchase if death==1


*************************************
***TABLE A.2 - Descriptive Statistics
*************************************

*new members data 

use newmembersdata.dta, clear

replace totspanishdeath = totspanishdeath*100

#delimit ;
sutex year  distfuture
totspanishdeath  
rprice1 lrprice difprice lgprice, nobs minmax;
#delimit cr


*composition data

use composition.dta, clear

#delimit ;
sutex shpeninsular chshspain, minmax nobs;
#delimit cr


*new members data

use newmembersdata.dta, clear

#delimit ;
sutex shsold shspain shspuniv shdr shba shlic shlimawife shfamcon
shdisp shprop shmerchant, minmax nobs;
#delimit cr

#delimit ;
sutex chshsold chshspain chshspuniv chshdr chshba chshlic chshlimawife chshfamcon
chshdisp chshprop chshmerchant, minmax nobs;
#delimit cr


*Provincial Traits

#delimit ;
sutex bishop pop54 ind54 lreparto rep50 mine wage forastero
tribut circuito suitindex z distlima, minmax nobs;
#delimit cr


*************************************
***FIGURE A.1 - Similarity in Datasets
*************************************

use fig2, clear

label var per_spaincomp "All Members Data"
label var shspain "New Member Data"

twoway(line per_spaincomp year if year<=1751, sort lcolor(black) lpattern(dash)) (line shspain year if year<=1751, sort lcolor(black)), legend( on rows(1) size(small) region(col(white))) xtitle("Year") ytitle("% Spanish Audiencia Members") graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white))

graph save figA1, replace


*****************************************
***TABLE A.3 - Timing of Deaths and War  
*****************************************

use limadeparty.dta, clear

*Panel A: Using 1 year window

*War indicator

reg death war, r
outreg2 using TableA3A.tex,  replace se bdec(3) tdec(3) nocons nor noni
reg death war year, r
outreg2 using TableA3A.tex,  append se bdec(3) tdec(3) nocons nor noni
reg deathspain war, r
outreg2 using TableA3A.tex,  append se bdec(3) tdec(3) nocons nor noni
reg deathspain war year, r
outreg2 using TableA3A.tex,  append se bdec(3) tdec(3) nocons nor noni

*Length of War

reg death cumwar, r
outreg2 using TableA3A.tex,  append se bdec(3) tdec(3) nocons nor noni
reg death cumwar year, r
outreg2 using TableA3A.tex,  append se bdec(3) tdec(3) nocons nor noni
reg deathspain cumwar, r
outreg2 using TableA3A.tex,  append se bdec(3) tdec(3) nocons nor noni
reg deathspain cumwar year, r
outreg2 using TableA3A.tex,  append se bdec(3) tdec(3) nocons nor noni



*Panel B: Using 2 year window

gen year2=2*round(year/2)

collapse (sum) death deathspain (median) war cumwar, by(year2)

*War indicator

reg death war, r
outreg2 using TableA3B.tex, replace se bdec(3) tdec(3) nocons nor noni
reg death war year, r
outreg2 using TableA3B.tex, append se bdec(3) tdec(3) nocons nor noni
reg deathspain war, r
outreg2 using TableA3B.tex, append se bdec(3) tdec(3) nocons nor noni
reg deathspain war year, r
outreg2 using TableA3B.tex, append se bdec(3) tdec(3) nocons nor noni

*Length of War

reg death cumwar, r
outreg2 using TableA3B.tex, append se bdec(3) tdec(3) nocons nor noni
reg death cumwar year, r
outreg2 using TableA3B.tex, append se bdec(3) tdec(3) nocons nor noni
reg deathspain cumwar, r
outreg2 using TableA3B.tex, append se bdec(3) tdec(3) nocons nor noni
reg deathspain cumwar year, r
outreg2 using TableA3B.tex, append se bdec(3) tdec(3) nocons nor noni


***************************************************************
***TABLE A.4: Timing of Death and Decision to Sell Positions
***************************************************************

use provpanel.dta, clear

merge m:1 year using limadeparty.dta
keep if _merge==3 //only those for post-1687 years 
drop _merge


reg sale death, r
outreg2 using TableA4.tex, replace se bdec(3) tdec(3) nocons nor noni
reg sale death year, r
outreg2 using TableA4.tex, append se bdec(3) tdec(3) nocons nor noni
reg sale deathspain, r
outreg2 using TableA4.tex, append se bdec(3) tdec(3) nocons nor noni
reg sale deathspain year, r
outreg2 using TableA4.tex, append se bdec(3) tdec(3) nocons nor noni


*******************************************************
***TABLE A.5: Timing of Death and Silver Production *******************************************************

use limadeparty.dta, clear

gen audiencia="Lima"

merge 1:1 audiencia year using lima_timeseries.dta
drop _merge

encode audiencia, gen(audcode)
xtset audcode year


gen lsilver1 = log(silver_pesos)
gen difsilv1 = lsilver1 - l.lsilver1

gen lsilver2 = log(silver_pesos2)
gen difsilv2 = lsilver2 - l.lsilver2

gen difdeath = death - l.death
gen difdeathspain = deathspain - l.deathspain


*Silver measure based on official registered entries
reg difsilv1 difdeath, r
outreg2 death using TableA5.tex, replace se bdec(2) tdec(3) nocons nor noni 
reg difsilv1 difdeathspain, r
outreg2 deathspain using TableA5.tex, append se bdec(2) tdec(3) nocons nor noni 
reg difsilv1 difdeath year, r
outreg2 death using TableA5.tex, append se bdec(3) tdec(3) nocons nor noni 
reg difsilv1 difdeathspain year, r
outreg2 deathspain using TableA5.tex, append se bdec(3) tdec(3) nocons nor noni 


*Silver measure based on mintage and mercury production 
reg difsilv2 difdeath
outreg2 death using TableA5.tex, append se bdec(3) tdec(3) nocons nor noni 
reg difsilv2 difdeathspain
outreg2 deathspain using TableA5.tex, append se bdec(3) tdec(3) nocons nor noni 
reg difsilv2 difdeath year
outreg2 death using TableA5.tex, append se bdec(3) tdec(3) nocons nor noni 
reg difsilv2 difdeathspain year
outreg2 deathspain using TableA5.tex, append se bdec(3) tdec(3) nocons nor noni



*****************************************************************
***TABLE A.6: Timing of Death and Inflation
*****************************************************************

use limadeparty.dta, clear

gen audiencia="Lima"

merge 1:1 audiencia year using lima_timeseries.dta
keep if _merge==3
drop _merge

encode audiencia, gen(audcode)
xtset audcode year

gen difdeath = death - l.death
gen difdeathspain = deathspain - l.deathspain
gen difindex = avgprice_index - l.avgprice_index



reg difindex difdeath, r
outreg2 difdeath using TableA6.tex, replace se bdec(3) tdec(3) nocons nor noni
reg difindex difdeathspain, r
outreg2 difdeathspain using TableA6.tex, append se bdec(3) tdec(3) nocons nor noni
reg difindex difdeath year, r
outreg2 difdeath using TableA6.tex, append se bdec(3) tdec(3) nocons nor noni
reg difindex difdeathspain year, r
outreg2 difdeathspain using TableA6.tex, append se bdec(3) tdec(3) nocons nor noni


*****************************************************************
***TABLE A.7: Timing of Death and Spain's Economic Fundamentals
*****************************************************************

use spain_timeseries.dta, replace

merge 1:1 year using limadeparty
keep if _merge==3
drop _merge

tsset year

gen lrevenue = log(revenue)
gen lgdppc = log(gdp_pc)

gen difrev = lrevenue - l.lrevenue
gen difgdp = lgdppc - l.lgdppc
gen difprice = eggprice_silver - l.eggprice_silver
gen difexch = conversion_vellon - l.conversion_vellon

gen difdeath = death - l.death
gen difspain = deathspain - l.deathspain



*Revenue

reg difrev difdeath, r
outreg2 difdeath using TableA7.tex, replace se bdec(3) tdec(3) nocons nor noni 
reg difrev difspain, r
outreg2 difspain using TableA7.tex, append se bdec(3) tdec(3) nocons nor noni


*GDP per capita

reg difgdp difdeath, r
outreg2 difdeath using TableA7.tex, append se bdec(3) tdec(3) nocons nor noni 
reg difgdp difspain, r
outreg2 difspain using TableA7.tex, append se bdec(3) tdec(3) nocons nor noni 


*Exchange Rates

reg difexch difdeath, r
outreg2 difdeath using TableA7.tex, append se bdec(3) tdec(3) nocons nor noni 
reg difexch difspain, r
outreg2 difspain using TableA7.tex, append se bdec(3) tdec(3) nocons nor noni 


*Pride Indices

reg difprice difdeath, r
outreg2 difdeath using TableA7.tex, append se bdec(3) tdec(3) nocons nor noni 
reg difprice difspain, r
outreg2 difspain using TableA7.tex, append se bdec(3) tdec(3) nocons nor noni 


***********************************************************************
***TABLE A.8: Individual Determinants of Deaths
***********************************************************************

use indivmemberslima.dta, clear

reg death length, r
outreg2 using TableA8.tex, replace se bdec(3) tdec(3) nocons nor noni
reg death length dob, r
outreg2 using TableA8.tex, append se bdec(3) tdec(3) nocons nor noni
reg death length entry, r
outreg2 using TableA8.tex, append se bdec(3) tdec(3) nocons nor noni
reg death length entry birthspain, r
outreg2 using TableA8.tex, append se bdec(3) tdec(3) nocons nor noni
reg death length entry purchase, r
outreg2 using TableA8.tex, append se bdec(3) tdec(3) nocons nor noni
reg length purchase
outreg2 using TableA8.tex, append se bdec(3) tdec(3) nocons nor noni
reg length birthspain
outreg2 using TableA8.tex, append se bdec(3) tdec(3) nocons nor noni


***********************************************************************
***FIGURES A.2-A.5: Reduced Form Binned Scatterplots
***********************************************************************


*Figure A.2

use newmembersdata.dta, clear

binscatter difprice totspanishdeath if distfuture<=9,  absorb(year) control(distfuture) ytitle("Change in Prices Between Sales (levels)") xtitle("Cumulative % of Spanish Deaths Between Sales (<=9 years)") graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) title("New Members Dataset")

graph save figA2, replace

areg difprice totspanishdeath distfuture if distfuture<=9, abs(year) cluster(provcode)


*Figure A.3

use newmembersdata.dta, clear

binscatter lgprice totspanishdeath if distfuture<=9,  absorb(year) control(distfuture) ytitle("Change in Prices Between Sales (log growth rates)") xtitle("Cumulative % of Spanish Deaths Between Sales (<=9 years)") graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) title("New Members Dataset")

graph save figA3, replace

areg lgprice totspanishdeath distfuture if distfuture<=9, abs(year) cluster(provcode)


*Figure A.4

use composition.dta, clear

binscatter difprice totspanishdeath if distfuture<=9,  absorb(year) control(distfuture) ytitle("Change in Prices Between Sales (levels)") xtitle("Cumulative % of Spanish Deaths Between Sales (<=9 years)") graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) title("All Members Dataset")

graph save figA4, replace

areg difprice totspanishdeath distfuture if distfuture<=9, abs(year) cluster(provcode)


*Figure A.5

use composition.dta, clear

binscatter lgprice totspanishdeath if distfuture<=9,  absorb(year) control(distfuture) ytitle("Change in Prices Between Sales (log growth rates)") xtitle("Cumulative % of Spanish Deaths Between Sales (<=9 years)") graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) title("All Members Dataset")

graph save figA5, replace

areg lgprice totspanishdeath distfuture if distfuture<=9, abs(year) cluster(provcode)


***********************************************************************
***TABLE A.9: Reduced Form Estimates
***********************************************************************

*new members data

use newmembersdata.dta, clear

replace totspanishdeath = totspanishdeath*100

keep if distfuture<=9

#delimit ;
xi: areg difprice totspanishdeath
distfuture i.year, abs(provcode) cluster(provcode);
sum difprice if e(sample);
local mean = r(mean);
outreg2 using TableA9.tex, replace pvalue bdec(3) tdec(3) nocons noni
adds("Provinces", e(N_clust), "Mean DV", `mean');
#delimit cr


#delimit ;
areg lgprice totspanishdeath
distfuture i.year, abs(provcode) cluster(provcode);
sum lgprice if e(sample);
local mean = r(mean);
outreg2 using TableA9.tex, append pvalue bdec(3) tdec(3) nocons noni
adds("Provinces", e(N_clust), "Mean DV", `mean');
#delimit cr


*composition data

use composition.dta, clear

replace totspanishdeath = totspanishdeath*100

keep if distfuture<=9

#delimit ;
areg difprice totspanishdeath
distfuture i.year, abs(provcode) cluster(provcode);
sum difprice if e(sample);
local mean = r(mean);
outreg2 using TableA9.tex, append pvalue bdec(3) tdec(3) nocons noni
adds("Provinces", e(N_clust), "Mean DV", `mean');
#delimit cr


#delimit ;
areg lgprice totspanishdeath
distfuture i.year, abs(provcode) cluster(provcode);
sum lgprice if e(sample);
local mean = r(mean);
outreg2 using TableA9.tex, append pvalue bdec(3) tdec(3) nocons noni
adds("Provinces", e(N_clust), "Mean DV", `mean');
#delimit cr



**************************************************************
***TABLE A.10: OLS vs IV in post-1717 sample
**************************************************************

*new members data

use newmembersdata.dta, clear

#delimit;
local replace replace;
foreach var of varlist difprice lgprice {;
xi: xtreg `var' chshsold distfuture i.year obyear1-obyear8 if year>=1717 & distfuture<=9, fe cluster(provcode);
sum `var' if e(sample);
local mean = r(mean);
outreg2 using TableA10.tex, `replace' pvalue bdec(3) tdec(3) nocons  noni
adds("Provinces", e(N_clust), "Mean DV", `mean');
local replace;
};
#delimit cr

#delimit;
foreach var of varlist difprice lgprice {;
xi: xtreg `var' chshspain distfuture i.year obyear1-obyear8 if year>=1717 & distfuture<=9, fe cluster(provcode);
sum `var' if e(sample);
local mean = r(mean);
outreg2 using TableA10.tex, append pvalue bdec(3) tdec(3) nocons  noni
adds("Provinces", e(N_clust), "Mean DV", `mean');
};
#delimit cr


*composition data

use composition.dta, clear

#delimit;
foreach var of varlist difprice lgprice {;
xi: xtreg `var' chshspain distfuture i.year obyear1-obyear8 if year>=1717 & distfuture<=9, fe cluster(provcode);
sum `var' if e(sample);
local mean = r(mean);
outreg2 using TableA10.tex, append pvalue bdec(3) tdec(3) nocons  noni
adds("Provinces", e(N_clust), "Mean DV", `mean');
};
#delimit cr


***********************************************************************
***TABLE A.11: Audiencia deaths and office prices: Different IV Samples
***********************************************************************

*new members data

use newmembersdata, clear

*PANEL A

#delimit ;
local replace replace;
foreach x in 4 9 16{;
xi: xtivreg2 difprice (chshsold = totspanishdeath)  obyear1-obyear8 i.year 
distfuture if distfuture<=`x', fe cluster(provcode) first 
partial(obyear* distfuture _I*);
sum difprice if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA11A.tex, `replace' dec(1) nocons nor noni
adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace append;
};
#delimit cr


#delimit ;
local replace append;
foreach x in 4 9 16{;
xi: xtivreg2 difprice (chshspain = totspanishdeath)  obyear1-obyear8 i.year 
distfuture if distfuture<=`x', fe cluster(provcode) first 
partial(obyear* distfuture _I*);
sum difprice if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA11A.tex, `replace' dec(1) nocons nor noni
adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace append;
};
#delimit cr


*PANEL B

#delimit ;
local replace replace;
foreach x in 4 9 16{;
xi: xtivreg2 lgprice (chshsold = totspanishdeath) obyear1-obyear8 i.year distfuture 
if distfuture<=`x', fe cluster(provcode) first partial(obyear* distfuture _I*);
sum difprice if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA11B.tex, `replace' dec(3) nocons nor noni
adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace append;
};
#delimit cr


#delimit ;
local replace append;
foreach x in 4 9 16{;
xi: xtivreg2 lgprice (chshspain = totspanishdeath) obyear1-obyear8 i.year distfuture 
if distfuture<=`x', fe cluster(provcode) first partial(obyear* distfuture _I*);
sum difprice if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA11B.tex, `replace' dec(3) nocons nor noni
adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace append;
};
#delimit cr


***************************************************************
***TABLE A.12: CLUSTERING STANDARD ERRORS AT THE LEVEL OF YEAR
***************************************************************

*New members data

use newmembersdata, clear

#delimit;
local replace replace;
foreach var of varlist difprice lgprice {;
xi: ivreg2 `var' (chshsold = totspanishdeath) obyear1-obyear8 i.year i.provcode distfuture if distfuture<=9, cluster(year)
first partial (obyear* distfuture _I*);
sum `var' if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  tableA12.tex, `replace' dec(3) nocons nor noni
adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace append;
};
#delimit cr


#delimit;
local replace append;
foreach var of varlist difprice lgprice {;
xi: ivreg2 `var' (chshspain = totspanishdeath) obyear1-obyear8 i.year i.provcode distfuture if distfuture<=9, cluster(year)
first partial (obyear* distfuture _I*);
sum `var' if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  tableA12.tex, `replace' dec(3) nocons nor noni 
adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace;
};
#delimit cr


*composition data

use composition, clear

#delimit;
local replace append;
foreach var of varlist difprice lgprice {;
xi: ivreg2 `var' (chshspain = totspanishdeath) obyear1-obyear8 i.year i.provcode distfuture if distfuture<=9, cluster(year)
first partial (obyear* distfuture _I*);
sum `var' if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  tableA12.tex, `replace' dec(3) nocons nor noni 
adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace;
};
#delimit cr


******************************************************************
***FIGURE A.6 AND A.7: Robustness to Outliers (Province and Year)
*******************************************************************

*Figure A.6 (leaving out one province at time)

use newmembersdata, clear


#delimit ;
xi: xtivreg2 lgprice (chshsold = 
totspanishdeath) obyear1-obyear8
i.year 
distfuture if distfuture<=9, fe cluster(provcode)
first partial (obyear* distfuture _I*);
#delimit cr

keep if e(sample) 

egen code = group(provcode)
tab code


# delimit ;
forvalues i=1(1)46 {; qui
xi: xtivreg2 lgprice (chshsold = totspanishdeath) obyear1-obyear8 i.year distfuture if distfuture<=9 & code!=`i', fe cluster(provcode) first partial (obyear* distfuture _I*);
qui parmest, saving ("tf`i'", replace);
};
# delimit cr

# delimit ;
use "tf1", clear;
foreach i of numlist 2/46{;
append using "tf`i'";
};
# delimit cr
	
format estimate min95 max95 z %8.2f
gen id = _n
label var z "Z-Statistic"
label var estimate "Coefficient"


twoway (line estimate id, lcolor(black) lpattern(solid) ylabel(0.012(0.002)0.02) ytitle("Coefficient on Log Growth Rates (col 2 table 3)", size(small)) sort) (line z id,  sort lcolor(black) lpattern(dash) yaxis(2) yline(1.96, axis(2)) ytitle("Z-Statistic on Log Growth Rates (col 2 table 3)", size(small) axis(2)) ylabel(1(1)4, axis(2))), xtitle("Provincial Code") graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white))

graph save figA6, replace

local list : dir . files "*tf*.dta"
foreach f of local list {
    erase "`f'"
}


******************************************
*Figure A.7 (leaving out one year at time)
******************************************

use newmembersdata, clear

#delimit ;
xi: xtivreg2 lgprice (chshsold = 
totspanishdeath) obyear1-obyear8
i.year 
distfuture if distfuture<=9, fe cluster(provcode)
first partial (obyear* distfuture _I*);
#delimit cr

keep if e(sample) 

egen code = group(year)
tab code


# delimit ;
forvalues i=1(1)49 {; qui
xi: xtivreg2 lgprice (chshsold = totspanishdeath) obyear1-obyear8 i.year distfuture if distfuture<=9 & code!=`i', fe cluster(provcode) first partial (obyear* distfuture _I*);
qui parmest, saving ("tf`i'", replace);
};
# delimit cr

# delimit ;
use "tf1", clear;
foreach i of numlist 2/49{;
append using "tf`i'";
};
# delimit cr

	
format estimate min95 max95 z %8.2f
gen id = _n
label var z "Z Stat"
label var estimate "Coefficient"


label define labcode 1"1688"	2"1689"	3"1690"	4"1691"	5"1692"	6"1693"	7"1694"	8"1695"	9"1696"	10"1697"	11"1698"	12"1700"	13"1704"	14"1705"	15"1706"	16"1707"	17"1708"	18"1709"	19"1710"	20"1711"	21"1712"	22"1713"	23"1714"	24"1715"	25"1716"	26"1717"	27"1718"	28"1719"	29"1720"	30"1728"	31"1731"	32"1732"	33"1734"	34"1735"	35"1736"	36"1737"	37"1738"	38"1739"	39"1740"	40"1741"	41"1742"	42"1744"	43"1745"	44"1746"	45"1747"	46"1748"	47"1749"	48"1750"	49"1751"

label values id labcode

twoway (line estimate id, lcolor(black) lpattern(solid) ylabel(0.012(0.002)0.02) ytitle("Coefficient on Log Growth Rates (col 2 table 3)", size(small)) sort) (line z id,  sort lcolor(black) lpattern(dash) yaxis(2) yline(1.96, axis(2)) ytitle("Z-Statistic on Log Growth Rates (col 2 table 3)", size(small) axis(2)) ylabel(1(1)4, axis(2))),  xtitle("Year Excluded") xlabel(1(4)49,valuelabel labsize(small) alternate) graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white))

graph save figA7, replace

local list : dir . files "*tf*.dta"
foreach f of local list {
    erase "`f'"
}


*********************************************************************
***TABLE A.13: Eliminating influential observations from Baseline Estimates (Table 3) using Cook's Distance
*********************************************************************

set seed 1984


*new members data

use newmembersdata, clear


*Column 1

#delimit;
xi: reg chshsold 
    totspanishdeath
    i.year i.provcode
    distfuture if distfuture<=9;
	predict cooksd1, cooksd;
	gen N1 = e(N) if e(sample);
#delimit cr


#delimit;
xi: xtivreg2 difprice (chshsold = 
    totspanishdeath) obyear1-obyear8
    i.year 
    distfuture if distfuture<=9 & cooksd1<4/N1, fe cluster(provcode)
    first partial (obyear* distfuture _I*);
	sum difprice if e(sample);
	local mean = r(mean);
	local fstat = e(widstat);
	outreg2 using  TableA13.tex, replace dec(3) nocons nor noni 
	adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
#delimit cr


*Column 2

use newmembersdata, clear


#delimit;
xi: reg chshsold 
    totspanishdeath
    i.year i.provcode
    distfuture if distfuture<=9;
	predict cooksd2, cooksd;
	gen N2 = e(N) if e(sample);
#delimit cr


#delimit;
xi: xtivreg2 lgprice (chshsold = 
    totspanishdeath) obyear1-obyear8
    i.year
    distfuture if distfuture<=9 & cooksd2<4/N2, fe cluster(provcode)
    first partial (obyear* distfuture _I*);
	sum lgprice if e(sample);
	local mean = r(mean);
	local fstat = e(widstat);
	outreg2 using  TableA13.tex, append dec(3) nocons nor noni 
	adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
#delimit cr


*Column 3

use newmembersdata, clear

#delimit;
xi: reg chshspain 
    totspanishdeath
    i.year i.provcode
    distfuture if distfuture<=9;
	predict cooksd3, cooksd;
	gen N3 = e(N) if e(sample);
#delimit cr


#delimit;
xi: xtivreg2 difprice (chshspain = 
    totspanishdeath) obyear1-obyear8
    i.year
    distfuture if distfuture<=9 & cooksd3<4/N3, fe cluster(provcode)
    first partial (obyear* distfuture _I*);
	sum difprice if e(sample);
	local mean = r(mean);
	local fstat = e(widstat);
	outreg2 using  TableA13.tex, append dec(3) nocons nor noni 
	adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
#delimit cr


*Column 4

use newmembersdata, clear

#delimit;
xi: reg chshspain 
    totspanishdeath
    i.year i.provcode
    distfuture if distfuture<=9;
	predict cooksd4, cooksd;
	gen N4 = e(N) if e(sample);
#delimit cr


#delimit;
xi: xtivreg2 lgprice (chshspain = 
    totspanishdeath) obyear1-obyear8
    i.year 
    distfuture if distfuture<=9 & cooksd4<4/N4, fe cluster(provcode)
    first partial (obyear* distfuture _I*);
	sum lgprice if e(sample);
	local mean = r(mean);
	local fstat = e(widstat);
	outreg2 using  TableA13.tex, append dec(3) nocons nor noni 
	adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
#delimit cr


*Column 5

use composition.dta, clear


#delimit;
xi: reg chshspain 
    totspanishdeath
    i.year i.provcode
    distfuture if distfuture<=9;
	predict cooksd5, cooksd;
	gen N5 = e(N) if e(sample);
#delimit cr


#delimit;
xi: xtivreg2 difprice (chshspain = 
    totspanishdeath) obyear1-obyear8
    i.year
    distfuture if distfuture<=9 & cooksd5<4/N5, fe cluster(provcode)
    first partial (obyear* distfuture _I*);
	sum difprice if e(sample);
	local mean = r(mean);
	local fstat = e(widstat);
	outreg2 using  TableA13.tex, append dec(3) nocons nor noni 
	adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
#delimit cr


*Column 6

use composition.dta, clear


#delimit;
xi: reg chshspain 
    totspanishdeath
    i.year i.provcode
    distfuture if distfuture<=9;
	predict cooksd6, cooksd;
	gen N6 = e(N) if e(sample);
#delimit cr


#delimit;
xi: xtivreg2 lgprice (chshspain = 
    totspanishdeath) obyear1-obyear8
    i.year
    distfuture if distfuture<=9 & cooksd6<4/N6, fe cluster(provcode)
    first partial (obyear* distfuture _I*);
	sum lgprice if e(sample);
	local mean = r(mean);
	local fstat = e(widstat);
	outreg2 using  TableA13.tex, append dec(3) nocons nor noni 
	adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
#delimit cr


***************************************************************
***TABLE A.14: Limit to Later Periods of Sample
***************************************************************

**********************
**Panel A - Post 1700
**********************

*new members data 

use newmembersdata, clear


#delimit;
local replace replace;
foreach var of varlist difprice lgprice {;
xi: xtivreg2 `var' (chshsold = totspanishdeath) obyear1-obyear8 i.year distfuture if distfuture<=9 & year>=1700, fe cluster(provcode)
first partial (obyear* distfuture _I*);
sum `var' if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA14A.tex, `replace' dec(3) nocons nor noni
adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace append;
};
#delimit cr


#delimit;
local replace append;
foreach var of varlist difprice lgprice {;
xi: xtivreg2 `var' (chshspain = totspanishdeath) obyear1-obyear8 i.year distfuture if distfuture<=9 & year>=1700, fe cluster(provcode)
first partial (obyear* distfuture _I*);
sum `var' if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA14A.tex, `replace' dec(3) nocons nor noni 
adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace;
};
#delimit cr


*composition data

use composition.dta, clear


#delimit;
local replace append;
foreach var of varlist difprice lgprice {;
xi: xtivreg2 `var' (chshspain = totspanishdeath) obyear1-obyear8 i.year distfuture if distfuture<=9 & year>=1700, fe cluster(provcode)
first partial (obyear* distfuture _I*);
sum `var' if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA14A.tex, `replace' dec(3) nocons nor noni 
adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace;
};
#delimit cr


**********************
**Panel B - Post 1710
**********************

*new members data

use newmembersdata, clear


#delimit;
local replace replace;
foreach var of varlist difprice lgprice {;
xi: xtivreg2 `var' (chshsold = totspanishdeath) obyear1-obyear8 i.year distfuture if distfuture<=9 & year>=1710, fe cluster(provcode)
first partial (obyear* distfuture _I*);
sum `var' if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA14B.tex, `replace' dec(3) nocons nor noni
adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace append;
};
#delimit cr


#delimit;
local replace append;
foreach var of varlist difprice lgprice {;
xi: xtivreg2 `var' (chshspain = totspanishdeath) obyear1-obyear8 i.year distfuture if distfuture<=9 & year>=1710, fe cluster(provcode)
first partial (obyear* distfuture _I*);
sum `var' if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA14B.tex, `replace' dec(3) nocons nor noni 
adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace;
};
#delimit cr


*composition data

use composition.dta, clear


#delimit;
local replace append;
foreach var of varlist difprice lgprice {;
xi: xtivreg2 `var' (chshspain = totspanishdeath) obyear1-obyear8 i.year distfuture if distfuture<=9 & year>=1710, fe cluster(provcode)
first partial (obyear* distfuture _I*);
sum `var' if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA14B.tex, `replace' dec(3) nocons nor noni 
adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace;
};
#delimit cr


**********************
**Panel C - Post 1720
**********************

*new members data

use newmembersdata, clear


#delimit;
local replace replace;
foreach var of varlist difprice lgprice {;
xi: xtivreg2 `var' (chshsold = totspanishdeath) obyear1-obyear8 i.year distfuture if distfuture<=9 & year>=1720, fe cluster(provcode)
first partial (obyear* distfuture _I*);
sum `var' if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA14C.tex, `replace' dec(3) nocons nor noni
adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace append;
};
#delimit cr


#delimit;
local replace append;
foreach var of varlist difprice lgprice {;
xi: xtivreg2 `var' (chshspain = totspanishdeath) obyear1-obyear8 i.year distfuture if distfuture<=9 & year>=1720, fe cluster(provcode)
first partial (obyear* distfuture _I*);
sum `var' if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA14C.tex, `replace' dec(3) nocons nor noni 
adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace;
};
#delimit cr


*composition data

use composition.dta, clear


#delimit;
local replace append;
foreach var of varlist difprice lgprice {;
xi: xtivreg2 `var' (chshspain = totspanishdeath) obyear1-obyear8 i.year distfuture if distfuture<=9 & year>=1720, fe cluster(provcode)
first partial (obyear* distfuture _I*);
sum `var' if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA14C.tex, `replace' dec(3) nocons nor noni 
adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace;
};
#delimit cr



***************************************************************
***TABLE A.15: Effects of Epidemics and Revisitas
***************************************************************

*PANEL A: Eliminating Cuzco and Huamanga

*new members data

use newmembersdata.dta, clear

drop if provincia=="Ciudad Cuzco" | provincia=="Huamanga"

#delimit;
local replace replace;
foreach var of varlist difprice lgprice {;
xi: xtivreg2 `var' (chshsold = totspanishdeath) i.year obyear1-obyear8 distfuture if distfuture<=9, fe cluster(provcode) first
 partial (obyear* distfuture _I*);
sum `var' if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA15A.tex, `replace' dec(2) nocons noni nor adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace;
};
#delimit cr



#delimit;
local replace append;
foreach var of varlist difprice lgprice {;
xi: xtivreg2 `var' (chshspain = totspanishdeath) i.year obyear1-obyear8 distfuture if distfuture<=9, fe cluster(provcode) first
 partial (obyear* distfuture _I*);
sum `var' if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA15A.tex, `replace' dec(2) nocons noni nor adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace;
};
#delimit cr


*composition data

use composition.dta, clear

#delimit;
local replace append;
foreach var of varlist difprice lgprice {;
xi: xtivreg2 `var' (chshspain = totspanishdeath) i.year obyear1-obyear8 distfuture if distfuture<=9, fe cluster(provcode) first partial (obyear* distfuture _I*);
sum `var' if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA15A.tex, `replace' dec(2) nocons noni nor adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace;
};
#delimit cr


**PANEL B: Eliminating Provinces "Revisited"

use newmembersdata.dta, clear


#delimit;
local replace replace;
foreach var of varlist difprice lgprice {;
xi: xtivreg2 `var' (chshsold = totspanishdeath) i.year obyear1-obyear8 distfuture if distfuture<=9 & revisita==0, fe cluster(provcode) first partial (obyear* distfuture _I*);
sum `var' if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA15B.tex, `replace' dec(2) nocons noni nor adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace;
};
#delimit cr


#delimit;
local replace append;
foreach var of varlist difprice lgprice {;
xi: xtivreg2 `var' (chshspain = totspanishdeath) i.year obyear1-obyear8 distfuture if distfuture<=9 & revisita==0, fe cluster(provcode) first partial (obyear* distfuture _I*);
sum `var' if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA15B.tex, `replace' dec(2) nocons noni nor adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace;
};
#delimit cr


*composition data

use composition.dta, clear


#delimit;
local replace append;
foreach var of varlist difprice lgprice {;
xi: xtivreg2 `var' (chshspain = totspanishdeath) i.year obyear1-obyear8 distfuture if distfuture<=9 & revisita==0, fe cluster(provcode) first partial (obyear* distfuture _I*);
sum `var' if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA15B.tex, `replace' dec(2) nocons noni nor adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace;
};
#delimit cr



**PANEL C: Controlling for alternatives e.g. wages, bishop seats, "forasteros"

*new members data

use newmembersdata, clear

gen bishyear = bishop*year
gen wageyear = wage*year
gen lforaster = log(forastero)
gen forasteroyear = lforaster*year

#delimit;
local replace replace;
foreach var of varlist difprice lgprice {;
xi: xtivreg2 `var' (chshsold = totspanishdeath) forasteroyear bishyear wageyear obyear1-obyear8 i.year*bishop i.year*wage i.year*lforaster i.year distfuture if distfuture<=9, fe cluster(provcode) partial (obyear* distfuture _I*);
sum `var' if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA15C.tex, `replace' dec(2) nocons noni nor adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace append;
};
#delimit cr



#delimit;
local replace append;
foreach var of varlist difprice lgprice {;
xi: xtivreg2 `var' (chshspain = totspanishdeath) forasteroyear bishyear wageyear obyear1-obyear8 i.year*bishop i.year*wage i.year*lforaster i.year distfuture if distfuture<=9, fe cluster(provcode) partial (obyear* distfuture _I*);
sum `var' if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA15C.tex, `replace' dec(2) nocons noni nor adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace append;
};
#delimit cr


*composition data

use composition, clear

gen bishyear = bishop*year
gen wageyear = wage*year
gen lforaster = log(forastero)
gen forasteroyear = lforaster*year

#delimit;
local replace append;
foreach var of varlist difprice lgprice {;
xi: xtivreg2 `var' (chshspain = totspanishdeath) forasteroyear bishyear wageyear obyear1-obyear8 i.year*bishop i.year*wage i.year*lforaster i.year distfuture if distfuture<=9, fe cluster(provcode) partial (obyear* distfuture _I*);
sum `var' if e(sample);
local mean = r(mean);
local fstat = e(widstat);
outreg2 using  TableA15C.tex, `replace' dec(2) nocons noni nor adds("Provinces", e(N_clust), "Mean DV", `mean', "F-Stat", `fstat');
local replace append;
};
#delimit cr


log close




